package com.controller.converter;

//import org.springframework.core.convert.converter.ConverterRegistry;
import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class OrderDateConverter implements Converter<String, Date>{
    @Override
    public Date convert(String source){
        //实现日期转换,controller层需要转换，否则报错400 bad request
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{
            return simpleDateFormat.parse(source);
        }catch (ParseException e){
            e.printStackTrace();
        }
        //参数绑定失败转换失败返回null
        return null;
    }


}
